using System;
using System.Collections.Generic;
using Framework.Core.Data;
using System.Reflection;

namespace Framework.Core.Search
{
    public static class SearchOperatorFactory
    {
        public static SearchOperatorItemCollection GetItems(DataBaseType dataBaseType, SearchItemType searchItemType)
        {
            SearchOperatorItemCollection items = new SearchOperatorItemCollection();

            if (searchItemType != SearchItemType.NoSet)
            {
                try
                {
                    Type type = Type.GetType(typeof(SearchOperatorFactory).Namespace + "." + dataBaseType.ToString() + searchItemType.ToString() + "SearchOperator");
                    object obj = Activator.CreateInstance(type);
                    PropertyInfo pi = type.GetProperty("Items");
                    if (!object.Equals(pi, null))
                    {
                        items = (SearchOperatorItemCollection)pi.GetValue(obj, null);
                    }
                }
                catch
                {
                }
            }
            return items;
        }
    }
}
